<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/8/25 10:52
 * Modified Time: 2019/8/25 10:52
 * Version: 2.0
 */

namespace App\Modules\MemberCard\Controllers;


use App\Lib\Facades\FLAuth;
use App\Modules\MemberCard\Services\MemberCardStatisticsService;
use App\Modules\MemberCard\Validators\MemberCardStatisticsControllerValidator;
use Flower\Core\Http\BaseController;
use Illuminate\Http\Request;

class MemberCardStatisticsController extends BaseController
{
    protected $memberCardStatisticsService;

    public function __construct(MemberCardStatisticsService $memberCardStatisticsService)
    {
        $this->memberCardStatisticsService = $memberCardStatisticsService;
    }

    public function getRules()
    {
        return MemberCardStatisticsControllerValidator::validator();
    }

    /*
     * 店铺会员卡统计
     */
    public function getMemberCardNum(Request $request)
    {
        $store_id = $request->input('store_id');
        $data = $this->memberCardStatisticsService->getMemberCardNum($store_id);
        return $this->display($data, '返回成功');
    }


    /*
     * 店铺某卡类会员卡统计
     */
    public function getTypeMemberCardNum(Request $request)
    {
        $store_id = $request->input('store_id');
        $card_type_id = $request->input('card_type_id');
        $data = $this->memberCardStatisticsService->getMemberCardNum($store_id,$card_type_id);
        return $this->display($data, '返回成功');
    }
    /*
     * 店铺会员卡统计
     */
    public function getOldMemberCardNum(Request $request)
    {
        $store_id = $request->input('store_id');
        $data = $this->memberCardStatisticsService->getOldMemberCardNum($store_id);
        return $this->display($data, '返回成功');
    }

    /*
     * 某张会员卡充值总额及余额统计
     */
    public function getMemberCardAmount(Request $request)
    {
        $member_card_id = $request->input('member_card_id');
        $data = $this->memberCardStatisticsService->getMemberCardAmount($member_card_id);
        return $this->display($data, '返回成功');
    }

    /*
     * 理发师会员卡统计
     */
    public function getBarberMemberCardNum(Request $request)
    {
        $user_id = FLAuth::id();
        $store_id = $request->input('store_id');
        $data = $this->memberCardStatisticsService->getBarberMemberCardNum($user_id,$store_id);
        return $this->display($data, '返回成功');
    }

    /*
     * 店铺会员卡类状态统计
     */
    public function getStatusMemberCardNum(Request $request)
    {
        $store_id = $request->input('store_id');
        $data = $this->memberCardStatisticsService->getStatusMemberCardNum($store_id);
        return $this->display($data, '返回成功');
    }
    /*
     * 理发师会员卡提成统计
     */
    public function getBarberMemberCardRoyalty(Request $request)
    {
        $user_id = FLAuth::id();
        $store_id = $request->input('store_id');
        $data = $this->memberCardStatisticsService->getBarberMemberCardRoyalty($user_id,$store_id);
        return $this->display($data, '返回成功');
    }

    /*
     * 获取某卡类办卡明细
     */
    public function getMemberCardByCardType(Request $request)
    {
        $card_type_id = $request->input('card_type_id');
        $pageSize = $request->input('pageSize',10);

        $data = $this->memberCardStatisticsService->getMemberCardByCardType($card_type_id,$pageSize);

        return $this->display($data);
    }

    /**
     * 会员卡申请统计
     * @param Request $request
     */
    public function getBarberMemberCardApplyNum(Request $request)
    {
        $store_id = $request->input('store_id');

        $data = $this->memberCardStatisticsService->getBarberMemberCardApplyNum($store_id);

        return $this->display($data);
    }
}